package com.ims.common.utils.sign;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.SM2;
import com.ims.common.exception.base.BaseException;
import org.springframework.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Base64;

/**
 * SM2加密方法
 *
 * @author IMS
 */
public class SM2Utils
{
//    private static final Logger log = LoggerFactory.getLogger(SM2Utils.class);
//
//    private static String pubKey = "04e0d5ff240e4fb4b16d0067bf0cea812774b6fe9719b80f7788a8f7c018abf27ee2a1cf727726632b8e757e0c43b63200ebd32736400b9658733cd693a3da5976";
//    private static SM2 sm2;
//
//    private static SM2 getDefualtSm2() {
//        if (sm2 == null) {
//            //公钥配置
//            sm2 = SmUtil.sm2(null, pubKey);
//        }
//        return sm2;
//    }
//
//    public static String encrypt(String data, String pubKey){
//        SM2 sm2ByPublicKey =SmUtil.sm2(null, pubKey);
//        //2、公钥加密
//        String encryptedBase64Data = sm2ByPublicKey.encryptBcd(data, KeyType.PublicKey);
//        System.out.println("通用加解密 ---> 加密后数据：" + encryptedBase64Data);
//        System.out.println("通用加解密 ---> 加密结束");
//        return encryptedBase64Data;
//    }
//
//    public static void main(String[] args) {
//        String data = "18321010206";
//        encrypt(data, pubKey);
//    }


}
